﻿#ifndef MSGSERVER_H
#define MSGSERVER_H

#include <QObject>
#include <QTcpServer>
#include "msgsocket.h"
#include "msgprocess.h"

class MsgServer : public QObject
{
    Q_OBJECT
signals:
    void signalUploadPicSuccessed();
    void signalShowImageServer(QImage image);
    void signalSaveCommentImage(const QString&,const QImage& image);
    void signalSaveHouseImage(const QString&,const QImage& image);
    void signalSaveHotelImage(const QString&,const QImage& image);
    void signalSaveUserHeadImage(const QString&,const QImage& image);
    void signalSaveUserCertImage(const QString&,const QImage& image);

public:
    explicit MsgServer(QObject *parent = nullptr);

public slots:
    void slotNewConnection();
    void slotSendMsgToClient(QString id, QString msg);
    void slotSendImageToClient(QString id, QString msg, QString path);
    void slotRegisterSocket(QString id, MsgSocket *socket);//保存新连接到map中
    void slotLogoutSocket(QString id, MsgSocket *socket);//从map中删除断开的连接

private:
    QTcpServer *m_tcpServer;
    MsgSocket *m_msgSocket;
    MsgProcess *m_msgProcess;
    SocketMap m_socketMap;
};

#endif // MSGSERVER_H
